﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Aker.DevTeam;

namespace Aker
{
    public partial class PriceUpdater : XPopupForm
    {
        
        public PriceUpdater()
        {
            InitializeComponent();
            
        }

        private void btnUpdate_Click(object sender, EventArgs e)
        {
            string hedef = "PriceDollar";
            switch (cmbTarget.SelectedIndex)
            {
                case 1:
                    hedef = "Price2Dollar";
                    break;
                case 2:
                    hedef = "Price3Dollar";
                    break;
            }
             
            decimal carpan = Convert.ToDecimal(spinner.EditValue) / 100;

            Data.DM.ExecuteNonQuery("UpdatePrices", hedef, carpan);
            Data.DM.ExecuteNonQuery("UpdEuroPrices", Settings.DollarEuroParity);

            this.DialogResult = System.Windows.Forms.DialogResult.OK;
        }

        private void PriceUpdater_Load(object sender, EventArgs e)
        {
            if (AppSession.Language == "TR")
            {
                cmbTarget.EditValue = "Acenta Fiyatı";
                cmbTarget.Properties.Items.AddRange(new object[] {
                "Baz Fiyat",
                "Acenta Fiyatı",
                "Fuar Fiyatı"});
            }
            else
            {
                cmbTarget.EditValue = "Agency Price";                
                cmbTarget.Properties.Items.AddRange(new object[] {
                "Base Price",
                "Agency Price",
                "Fair Price"});
            }

            this.Text = Language.PriceUpdater.PriceUpdaterHeader;
            btnUpdate.Text = Language.Save;
            lbl1.Text = Language.PriceUpdater.Formula;

        }
    }
}
